const behavior = require('../../behaviors/my-behavior')
Page({
  behaviors: [behavior],
  data: {
    countDownVisible: false,
    errmsg: '',
    mobile: '',
  },
  onShow() {
    this.validate()
  },
  countDownChange(ev) {
    console.log(ev.detail)
    this.setData({
      timeData: ev.detail,
      countDownVisible: ev.detail.minutes === 1 || ev.detail.seconds > 0,
    })
  },
  startCountDown() {
    // 验证手机号
    if (!this.data.mobile) return this.setData({ errmsg: '手机号不能为空' })
    if (!/^1[3-9]\d{9}$/.test(this.data.mobile)) return this.setData({ errmsg: '手机号格式不正确' })

    this.setData({ errmsg: '', countDownVisible: true })
  },
})
